﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands.UserAccount
{
    public record UnLockUserAccountCommand(long Id) : IRequest<bool>;

    public class UnLockUserAccountCommandHandler : IRequestHandler<UnLockUserAccountCommand, bool>
    {
        private readonly IUserAccountService _userAccountService;
        public UnLockUserAccountCommandHandler(IUserAccountService userAccountService)
            => _userAccountService = userAccountService;

        public async Task<bool> Handle(UnLockUserAccountCommand request, CancellationToken cancellationToken)
        {
            await _userAccountService.ModifyLockFlagAsync(request.Id, false);

            return true;
        }
    }
}
